<?php

class Content extends CActiveRecord
{
	/**
	 * The followings are the available columns in table 'tbl_comment':
	 * @var integer $id
	 * @var string $content
	 * @var integer $status
	 * @var integer $created
	 * @var string $author
	 * @var string $email
	 * @var string $url
	 * @var integer $post_id
	 */

	/**
	 * Returns the static model of the specified AR class.
	 * @return CActiveRecord the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{content}}';
	}
        
        public function scopes()
        {
            $now=new CDbExpression("NOW()");
            return array(
                'actual'=>array(
                    'condition'=>'startdate <='.$now.' and enddate >'.$now
                ),
            );
        }
        public function afterFind() {
            parent::afterFind();
            $pre = '';
            if($this->render==10){
                $pre= '<div class="ym-grid linearize-level-2">'
                        .'<div class="ym-g50 ym-gl">'
                        .'<div class="ym-gbox-left">';
                
            }
            if(!is_null($this->heading)) $this->heading=$pre.'<h6>'.$this->heading.'</h6>';
                else $this->heading=$pre;
                
                
            if($this->render==0) $this->content='<p class="content">'.$this->content.'</p>';
            elseif ($this->render==1) $this->content='<p class="indent">'.$this->content.'</p>';
            elseif ($this->render==10)$this->content='<p class="content">'.$this->content.'</div></div>'
                        .'<div class="ym-g50 ym-gr"'
                        .'<div class="ym-gbox-right">';
            elseif ($this->render==11)$this->content='<p class="content">'.$this->content.'</p></div></div></div>';
        }

	/**
	 * @return array validation rules for model attributes.

	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			//array('content, author, email', 'required'),
			//array('author, email, url', 'length', 'max'=>128),
			//array('email','email'),
			//array('url','url'),
		);
	}
	 */
	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
                );
	}

}